import Http from "../http";

export function merchantPaginationApi(params:any) {
    return Http.get('merchant/list', params)
}

export async function addMerchantApi(data:any) {
    return await Http.post('merchant/add', data)
}

export async function editMerchantApi(merchantId:number, data:any) {
    return await Http.put('merchant/edit/' + merchantId, data)
}

export async function getMerchantEditDataApi(merchantId:number) {
    const { data } = await Http.get('merchant/edit/' + merchantId)
    return data
}

export async function toggleMerchantStatusApi(merchantId:number, currentStatus:number) {
    let url = ''
    switch(currentStatus) {
        case 0 : url = 'enable'
            break
        case 1 : url = 'forbidden'
            break
    }

    const { success } = await Http.put('merchant/' + url + '/' + merchantId)

    return success
}


export async function queryMerchantNameApi(name:string) {
    return Http.get('merchant/list/' + name)
}